<!DOCTYPE html>
<html lang="en">
<head>
    <meta name="viewport"
          content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0,user-scalable=no">
    <meta charset="UTF-8">
    <title>横竖屏监听</title>
</head>
<body>
<div id="box"></div>
<script>
    /**
     * 可能的值为 0 90 -90
     * */
    alert(window.orientation);
    window.addEventListener("orientationChange",function (e) {
                setTimeout(alert(window.orientation),500);
    });
</script>
</body>
</html>